Skip to content

feat: add /maps/ routes - #2

Merged
gmaclennan merged 12 commits into
mainfrom
feat/maps-routes
Jan 21, 2026
Merged

feat: add /maps/ routes#2
gmaclennan merged 12 commits into
mainfrom
feat/maps-routes

Conversation

@gmaclennan

Copy link
Copy Markdown
Member

Adds routes for reading maps, uploading new custom maps, and deleting custom maps

@gmaclennan gmaclennan self-assigned this Dec 15, 2025
@gmaclennan
gmaclennan marked this pull request as ready for review December 15, 2025 21:00
@socket-security

socket-security Bot commented Dec 15, 2025

Copy link
Copy Markdown

@socket-security

This comment was marked as resolved.

@gmaclennan gmaclennan changed the title feat: add /maps/ routes feat: add /maps/ routes Dec 15, 2025
@gmaclennan

Copy link
Copy Markdown
Member Author

Some windows failures around parallel uploads, which I suspect are probably a test artifact rather than a bug to be worried about.

@gmaclennan

This comment was marked as resolved.

@RangerMauve RangerMauve left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not seeing any obvious issues

@achou11 achou11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small cleanup things to address but otherwise functionality seems thorough!

Out of curiosity, will I still need the patches I have on desktop related to CORS issues that I run into in development? (caused by usage of Vite's dev server)


Slightly tangential, but the publishing tsconfig needs to be updated since you're committing to a TS implementation:

diff --git a/tsconfig.npm.json b/tsconfig.npm.json
index f89cb7b..f35d2b4 100644
--- a/tsconfig.npm.json
+++ b/tsconfig.npm.json
@@ -4,9 +4,7 @@
 		"noEmit": false,
 		"outDir": "dist",
 		"declaration": true,
-		"emitDeclarationOnly": true,
 		"declarationMap": true
 	},
-	"files": [],
-	"include": ["src/index.js"]
+	"include": ["src/index.ts", "types/*"]
 }

Comment thread .github/workflows/node.yml Outdated
Comment thread .github/workflows/node.yml Outdated
Comment thread .github/workflows/node.yml Outdated
Comment thread .github/workflows/node.yml Outdated
Comment thread src/lib/utils.ts Outdated
Comment thread src/context.ts
Comment thread test/helpers.ts Outdated
Comment thread package.json
Comment thread package.json
Comment thread src/types.ts
achou11 added a commit to digidem/comapeo-desktop that referenced this pull request Dec 16, 2025
Updates the bounding box used for the map where there's no data to show.
Something I learned via
digidem/comapeo-map-server#2 (comment)
achou11 added a commit to digidem/comapeo-desktop that referenced this pull request Dec 16, 2025
Updates the bounding box used for the map where there's no data to show.
Something I learned via
digidem/comapeo-map-server#2 (comment)
@gmaclennan
gmaclennan requested a review from achou11 January 21, 2026 13:36

@achou11 achou11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few non-blocking comments but overall looks great ✨

Comment thread src/routes/maps.ts
Comment on lines +54 to +56
if (request.params.mapId !== CUSTOM_MAP_ID) {
throw new errors.MAP_NOT_FOUND(`Map not found: ${request.params.mapId}`)
}

@achou11 achou11 Jan 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels misleading to use a not found error here. maybe a status error explaining this temporary (?) limitation would be more suitable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix is lined up in #4, which adds a FORBIDDEN (403) for trying to update or delete the "special" IDs - fallback and default. I'm following a pattern here where PUT is for updates, not for creation (keeping POST for that), so I think 404 is the correct response. This is probably not perfectly semantically correct, given that this is also creating the custom map, but I think we can just resolve this later when we change this to support multiple custom maps.

Comment thread src/routes/maps.ts
Comment on lines +69 to +71
if (request.params.mapId !== CUSTOM_MAP_ID) {
throw new errors.MAP_NOT_FOUND(`Map not found: ${request.params.mapId}`)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar comment about potentially using a different error code

Comment thread src/routes/root.ts
Comment thread src/index.ts
Comment on lines +66 to +67
// @ts-expect-error - the types for this are too hard and making them work would not add any type safety.
remoteDeviceId: z32.encode(req.socket.remotePublicKey),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More specific placement to avoid unintentional opt-out:

Suggested change
// @ts-expect-error - the types for this are too hard and making them work would not add any type safety.
remoteDeviceId: z32.encode(req.socket.remotePublicKey),
remoteDeviceId: z32.encode(
// @ts-expect-error - the types for this are too hard and making them work would not add any type safety.
req.socket.remotePublicKey,
),

Comment thread test/maps.test.ts
@gmaclennan
gmaclennan merged commit 47499d7 into main Jan 21, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants